home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * MacZoop - "the framework for the rest of us"
- *
- *
- *
- * ZScroller.h -- a window with scrollbars
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
-
- #pragma once
-
- #ifndef __ZSCROLLER__
- #define __ZSCROLLER__
-
- #include "ZWindow.h"
-
- /*
- ZScroller is a window that has scrollbars in the usual way. The scrollBounds sets the size
- of the area that the window can show- if this is ever less than the window content the
- scrollbars will be disabled. The scale values set how many pixels to move in each direction
- for each increment of the scrollbar. Override this class to implement scrolling windows with
- REAL content.
- */
-
-
- // set up streaming stuff:
-
- DEFINECLASSID( ZScroller, 'zscr' );
-
- // class def:
-
- class ZScroller : public ZWindow
- {
- protected:
- ControlHandle theHBar; // handle to horizontal scrollbar
- ControlHandle theVBar; // handle to vertical scrollbar
- Rect bounds; // scrollable area (virtual document size)
- short hScale; // pixels shifted per unit horizontally
- short vScale; // pixels shifted per until vertically
- Boolean hasHBar; // true if has horizontal bar
- Boolean hasVBar; // true if has vertical bar
- short cInitValue; // used for live scrolling support
-
- public:
-
- ZScroller( ZCommander* aBoss,
- const short windID,
- const Boolean hasHScroll = TRUE,
- const Boolean hasVScroll = TRUE );
-
- ZScroller();
-
- // ZWindow overrides:
- virtual void InitZWindow();
- virtual void Activate();
- virtual void Deactivate();
- virtual void Draw();
- virtual void DrawGrow();
- virtual void Click( const Point mouse, const short modifiers );
- virtual void SetSize( const short width, const short height, const Boolean reDraw = TRUE);
- virtual void Zoom( const short partCode );
- virtual void SetBounds( const Rect& aBounds );
- virtual void SetBounds( short top, short left, short bottom, short right );
- virtual void SetBounds( Point tl, Point br );
- virtual void GetBounds( Rect* aBounds );
- virtual void GetIdealWindowZoomSize( Rect* idealSize );
-
- virtual void GetContentRect( Rect* aRect );
- virtual void ClickContent( const Point mouse, const short modifiers ) {};
-
- // ZScroller methods:
- virtual void SetScrollAmount( const short hAmount, const short vAmount );
- virtual void GetPosition( short* hPosition, short* vPosition );
- virtual void ScrollTo( const short hPosition, const short vPosition );
- virtual void Scroll( const short dH, const short dV );
-
- virtual Boolean AutoScroll( Point mousePt );
-
- // streaming:
-
- virtual void WriteToStream( ZStream* aStream );
- virtual void ReadFromStream( ZStream* aStream );
-
- protected:
-
- virtual void CalculateControlParams();
- virtual void MakeScrollbars();
- virtual void MoveScrollbars();
- virtual void PostScroll( ControlHandle aCtl = NULL );
- virtual void SetOriginToScroll();
- virtual void HideScrollbars( Boolean validateArea = FALSE );
-
- public:
-
- virtual void ScrollHandler( const ControlHandle aCtl, const short partCode );
- };
-
-
-
- // compiler flags:
-
- // ZScroller by default sets up a thumb action procedure to implement "live scrolling". If you'd
- // prefer to use the more traditional non-live scrolling, undefine the following conditional.
-
- #define _LIVE_SCROLLING 1
-
- // for live scrolling we require a UPP definition for the thumb proc- Apple's interfaces
- // omit this, so we do that here
-
- #ifdef _LIVE_SCROLLING
-
- #define kWidthOfScrollArrow 24
-
- // UPP:
-
- typedef pascal void (*ThumbActionProcPtr)();
-
- #if GENERATINGCFM
- typedef UniversalProcPtr ThumbActionUPP;
- #else
- typedef ThumbActionProcPtr ThumbActionUPP;
- #endif
-
- enum
- {
- uppThumbActionProcInfo = kPascalStackBased
- };
-
- #if GENERATINGCFM
- #define NewThumbActionProc(userRoutine) \
- (ThumbActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppThumbActionProcInfo, GetCurrentArchitecture())
- #else
- #define NewThumbActionProc(userRoutine) \
- ((ThumbActionUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallThumbActionProc(userRoutine) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppThumbActionProcInfo )
- #else
- #define CallThumbActionProc(userRoutine ) \
- (*(userRoutine))()
- #endif
-
-
- #endif
-
- #endif